git pull
cd /home/code/xingzuo-webserver
mvn clean package -s settings.xml -Dmaven.test.skip=true
cp xingzuo-webserver-app/target/*.jar /home/app
cd /home/app


JARFILE=$(ls -l |grep  .jar | awk '{print$9}')
FILEPATH=$(pwd "$JARFILE")"/"$JARFILE
PID=$(ps -ef|grep -w "$FILEPATH" | grep -v grep |awk '{printf $2}')

echo "$FILEPATH"
if [ ! -n "$PID" ]; then
    echo "pid is null"
    nohup $JAVA_HOME/bin/java -Dlog4j2.formatMsgNoLookups=true -jar $FILEPATH --spring.profiles.active=test >> /dev/null 2>&1 &
    exit
else
    echo "pid not null"
fi

kill -9 ${PID}

if [ $? -eq 0 ];then
    echo "pid is $PID"
    echo "kill $JARFILE success"
    nohup $JAVA_HOME/bin/java -Dlog4j2.formatMsgNoLookups=true -jar $FILEPATH --spring.profiles.active=test >> /dev/null 2>&1 &
else
    echo "kill $JARFILE fail"
fi

tail -f nohup.out | sed '/Tomcat started on/q'

